import { defineStore } from 'pinia'
import { shopApi, waterApi } from '@/api/shop'
export const userShopStore = defineStore({
  id: 'shopStore',
  state: (): any => {
    return {
      shopSwiper: [],
      waterData: []
    }
  },
  actions: {
    async getShopStoreData() {
      const res: any = await shopApi()
      // console.log('res', res.navList);
      this.shopSwiper = res.navList
      // console.log(111);

    },
    async getWaterData(page: number, size: number) {
      const res: any = await waterApi(page, size)
      // console.log('res', res.result);
      this.waterData.push(...res.result)
      // console.log(111);

    }
  },
  getters: {
    topics(): any {
      if (this.waterData.length) {
        const arr: any = []
        this.waterData.forEach((item: any) => {
          arr.push(...item.topics, item.look)
        })
        return arr

      } else {
        return []
      }



    }
  }
})